<template>
  <div>
    <div class="content">
      <div class="return" @click="close">
        <img class="img1" src="../../assets/img/return.png" alt="" />
        <p class="return-p">返回</p>
      </div>
      <div class="card1" v-for="(item, index) in list" :key="index">
        <div class="card1-text">领取人：{{ item.phone }}</div>
        <div class="card1-text">时间：{{ item.time }}</div>
        <div class="card1-text">金额：{{ item.money }}</div>
        <div class="card1-text">有效期：{{ item.days }}</div>
      </div>
      <div class="norecords" v-if="list && list.length == 0">
        暂无记录
      </div>
    </div>
  </div>
</template>

<script>
import { voucherRecord, voucherUserRecord } from "@/api/fulfil.js";
export default {
  name:'record2',
  data() {
    return {
      agentid: "",
      list: [],
      role: "",
    };
  },
  mounted() {
    /* this.role = localStorage.getItem("role");
    this.getIndex(); */
  },
  activated() {
    this.role = localStorage.getItem("role");
    this.getIndex();
  },
  methods: {
    getIndex() {
      voucherUserRecord({
        agentid:
          this.role == 8
            ? localStorage.getItem("adminid")
            : localStorage.getItem("agentid"),
      })
        .then((res) => {
          this.list = res.data.data;
          console.log(res);
        })
        .catch((error) => {
          console.log(error);
        });
    },
    close() {
      window.history.go(-1);
    },
  },
};
</script>

<style scoped>
.content {
  padding-bottom: 0.3rem;
  overflow: hidden;
  width: 100%;
  min-height: 100vh;
  background: #e1f7fc;
}
.card1 {
  overflow: hidden;
  margin: 0.3rem auto 0;
  padding: 0 0 0.25rem 0.5rem;
  width: 84%;
  background: #fff;
  border-radius: 0.375rem;
}
.card1-title {
  margin-top: 0.2rem;
  font-size: 0.4125rem;
  font-weight: 600;
  color: #000;
}
.card1-text {
  margin: 0.25rem 0 0 0.2rem;
  font-size: 0.3125rem;
  font-weight: 600;
  color: #000;
}
.card1-text1 {
  margin: 0.25rem 0 0 0.2rem;
  font-size: 0.3125rem;
  font-weight: 600;
  color: #000;
  text-align: center;
}
.img1 {
  display: inline-block;
  width: 27px;
  height: 48px;
  vertical-align: middle;
}
.return {
  margin: 20px 0 0 30px;
  font-size: 40px;
}
.return-p {
  margin-left: 20px;
  display: inline-block;
  vertical-align: middle;
}
.norecords {
  margin-top: 2rem;
  color: #ffbe4c;
  font-size: .5rem;
  text-align: center;
}
</style>